import { InjectionToken, container } from "tsyringe";
import { tryGet } from "./tryGet";
import { CONFIG } from "../tokens/core";

export function configTokenFactory<T>(token: InjectionToken<T>, def?: T) {
    container.register(token, {
        useFactory: (c) => {
            const config = tryGet(CONFIG, c);
            return config.get(token)
        }
    })
}